<%-- 
    Document   : profile
    Created on : Apr 20, 2012, 3:32:03 PM
    Author     : Yasmani
--%>

<%-- 
    Document   : profile
    Created on : Apr 20, 2012, 3:03:36 PM
    Author     : hemanthparasa
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*,java.util.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="stars/jquery.rating.pack.js"></script>
        <script type="text/javascript" src="jquery-ui-1.8.20.custom.min"></script>
        <link href="jquery-ui-1.8.20.custom.css" rel="stylesheet" type="text/css" />
        <link href="stars/jquery.rating.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            $(".class").rating(
'method', // method name
[] // method arguments (not required)
);
    
        </script>
    </head>
    <body>
        
        <%
         String url = "jdbc:mysql://localhost:3306/ismi";
         Connection con;
         ResultSet rs;
          ResultSet rs1;
         String s;
         String user = request.getParameter("user").trim();
         System.out.println(user);
         String sqlstr = ("SELECT user_gname,user_wname,rating,comment,date,id from rating where user_gname ='"+user+"';");
      //   String sqlstr1 = ("SELECT * from user where user_name ='"+user+"';");
         %>
         <table>
            
            <tr>
                <td>Username:</td>
                <td><% out.println(user);%></td>
            </tr>
             <tr>
                
                <td>
                     <table>
                        <tr>
                            <td> Comment </td>
                            <td> UserName </td>
                            <td> Date</td>
                        </tr>
            <%
         
         
         /*String sqlstrdeleteuser = "DELETE from user where user_name = ";*/
         
         //System.out.println("we")
               try 
               {
                       Class.forName("com.mysql.jdbc.Driver");
                        System.out.println("00");
               } 
               catch(java.lang.ClassNotFoundException e) 
               {
                       System.err.print("ClassNotFoundException: ");
                       System.err.println(e.getMessage());
               }

               try  
               {
                       con = DriverManager.getConnection(url,"root", "isaac16");
                       /*System.out.println("1");*/
                       Statement st = con.createStatement();
                       //Statement stDelete = con.createStatement();
                       rs = st.executeQuery(sqlstr);
                       int s10=0;
                       float s11;
                       int i=0;
                          
                       while(rs.next()){
              
                       i++;
                       s10=s10+rs.getInt(3);
                        
                       
                       
                        
                      %>  
                     
        
           
            
           
                   
                        <tr>
                            <td><% out.println(rs.getString(4));%></td>
                            <td><% out.println(rs.getString(2));%></td>
                            <td><% out.println(rs.getDate(5));%></td>
                            <td><% out.println(rs.getInt(6));%></td>
                            <td>   </td>
                        </tr>
                        
                        <%}
                       if(i!=0){
                       s11=(float)s10/i;
                       }
                       else{
                           s11=0;
                       }
                       rs.close();
                       st.close();
                       con.close();
                       %>
                        <tr>
                <td>Rating:</td>
            </tr>
            <tr>                           
                <td><% out.println(s11);%></td>               
            </tr>
                       

             <%  } 
               catch(SQLException ex) 
               {
                       System.err.println("SQLException: " + ex.getMessage());
               }

               
           %>
                    </table>
                </td>
            </tr>
        </table>
                    <form action="Star"> 
                           Rate the person:
                            
	Rating: <span id="stars-cap"></span>
	<input name="star1" type="radio" value="1" class="star"/>
        <input name="star1" type="radio" value="2" class="star"/>
        <input name="star1" type="radio" value="3" class="star"/>
        <input name="star1" type="radio" value="4" class="star"/>
        <input name="star1" type="radio" value="5" class="star"/>
        <input name="cc" type="text" value=""/>
        <input type="submit" name="submit" value="submit">
     <input type="hidden" name="user" value="<% out.println(user);%>" />
        
                      </form>
    </body>
</html>
